<?php

/** 
 * 订单_控制器
 * @property Order_mdl $order
 */
class Order extends MY_Controller {
	
	public function __construct() {
		parent::__construct ();
		$this->user = parent::getLoginUser();
		$this->load->model('Order_mdl','order');
		
// 		$this->order->setUserID($this->user->id);
		
	}
	/**
	 * API:用户订单列表
	 * 输入参数:
	 * 		count:请求多少条
	 * 		bottomID:要获取的订单的最大ID
	 */
	public function index(){
		$input = &$_REQUEST;
		$bottomID = isset($input['bottomID']) ? (int)$input['bottomID'] : 0;
		$count    = isset($input['count'])    ? (int)$input['count']    : 20;
		$bottomID = $bottomID > 0 ? $bottomID : 0;
		$count    = $count    > 0 ? $count    : 20;
		
		$select = 'id,devID,type,beginTime,price,takeSec,amount,isFinish,alias';
		$where  = array();
		$where['userID'] = $this->user->id;
// 		$where['isFinish'] = 1;
		if ($bottomID > 0) {
			$where['id <'] = $bottomID;
		}
		$list = $this->order->getList($select,$where,$count+1,0,'id','DESC');
		$hasMore = 0;
		if( count($list) > $count ){
			$hasMore = 1;
			array_pop($list);
		}
		
		$this->apiOutput->put('hasMore',$hasMore)->put('list', $list)->out();
	}
	

	
	
	
	
	
	
	
	
}

